package org.demo.web.controller.ping;

import org.demo.domain.response.ResponseEnvelope;
import org.demo.domain.response.ResponseHeader;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
@RequestMapping (value = "/public")
public class PingResourceController {

	/* ---- Instance Variables ---- */

	/* ---- Constructors ---- */

	/* ---- Rest Methods ---- */

	/**
	 * Ping service, mainly used to see if a connection to the UPay server can be made. The
	 * service returns the given message.
	 *
	 * @param message
	 * @return
	 */
	@RequestMapping (value = "/ping", method = RequestMethod.GET)
	public @ResponseBody ResponseEnvelope<String> pingGET(
		@RequestParam(value="message", required=true) String message) {

        return new ResponseEnvelope<String>(
    	    new ResponseHeader(null, Boolean.TRUE, 0),
    	    new org.demo.domain.response.ResponseBody<String>(message, null));
	}

	/**
	 * Ping service, mainly used to see if a connection to the UPay server can be made. The
	 * service returns the given message.
	 *
	 * @param message
	 * @return
	 */
	@RequestMapping (value = "/ping", method = RequestMethod.POST)
	public @ResponseBody ResponseEnvelope<String> pingPOST(
		@RequestParam(value="message", required=true) String message) {

        return new ResponseEnvelope<String>(
    	    new ResponseHeader(null, Boolean.TRUE, 0),
    	    new org.demo.domain.response.ResponseBody<String>(message, null));
	}
	/* ---- Getters and Setters ---- */

}
